# Contributor: Lauren N. Liberda <lauren@selfisekai.rocks>
# Maintainer: Lauren N. Liberda <lauren@selfisekai.rocks>
pkgname=k3sup
pkgver=0.13.4
pkgrel=0
pkgdesc="A light-weight utility to get from zero to KUBECONFIG with k3s"
url="https://k3sup.dev/"
arch="all"
license="MIT"
makedepends="go"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/alexellis/k3sup/archive/refs/tags/$pkgver/k3sup-$pkgver.tar.gz"

# secfixes:
#   0.13.4-r0:
#     - CVE-2023-48795

prepare() {
	default_prepare

	mkdir -p bin/
}

build() {
	go build -a \
		-ldflags "-X github.com/alexellis/k3sup/cmd.Version=$pkgver" \
		-o bin/k3sup

	for i in bash fish zsh; do
		./bin/k3sup completion "$i" > "$builddir"/k3sup.$i
	done
}

check() {
	# shellcheck disable=SC2046
	go test $(go list ./... | grep -v /vendor/ | xargs) -cover
}

package() {
	install -Dm755 bin/k3sup "$pkgdir"/usr/bin/k3sup

	install -Dm644 "$builddir"/$pkgname.bash "$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -Dm644 "$builddir"/$pkgname.fish "$pkgdir"/usr/share/fish/vendor_completions.d/$pkgname.fish
	install -Dm644 "$builddir"/$pkgname.zsh "$pkgdir"/usr/share/zsh/site-functions/_$pkgname
}

sha512sums="
3afcd3f29f75c213808e825eb66a3ebe350615968553e06cd794c9d6e08c674ea929b0aca81821beabf3c5ec3042a71ccfc3c9d521f432c1ab47618a19953a8a  k3sup-0.13.4.tar.gz
"
